home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / Eric's C++ Libraries / Interface Classes / CPPVisualTreeNode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  3.7 KB  |  134 lines  |  [TEXT/KAHL]

  1. /***************************************************** IMPLEMENTATION
  2.     DATE:    10/28/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPVisualTreeNode
  6.     
  7.     SUPERCLASS: CPPTreeNode
  8.     
  9.         This C++ class manages the visual representation of a node
  10.         in a hierarchical tree
  11.     
  12. ********************************************************************/
  13.  
  14. #pragma once
  15.  
  16. #include <CPPTreeNode.h>
  17.  
  18. class CPPVisualTree;
  19.  
  20. #define    kSetSelect        1
  21. #define    kClearSelect    0
  22. #define    kToggleSelect    -1
  23.  
  24. #define    kEraseFamily    15
  25. #define    kDrawFamily        16
  26. #define    kResizeFamily    17
  27. #define    kMoveFamily        18
  28.  
  29. typedef enum  
  30.     {
  31.         kNoJoin = 0,        /* don't draw lines b/w nodes */
  32.         kPointToPoint,        /* draw a line directly b/w nodes */
  33.         kRightAngle            /* draw an aesthetically squared line b/w nodes */
  34.     } joinTypes;
  35.     
  36. typedef enum 
  37.     {
  38.         kTopDown    = 0,    /* draw the tree from top to bottom */
  39.         kBottomUp    = 1,    /* draw from bottom to top */
  40.         kRight2Left = 2,    /* draw from right to left */
  41.         kLeft2Right    = 3        /* draw from left to right */
  42.     } orientStyle;
  43.  
  44. typedef enum
  45.     {
  46.         kJustCenter = 0,    /* center the parent wrt the children */
  47.                             /* positioning constants for left2right/right2left displayStyle */
  48.         kJustLeft,            /* put the parent to the left of its children */
  49.         kJustRight,            /* put the parent to the right of its children */
  50.                             /* positioning constants for topdown/bottomup displayStyle*/
  51.         kJustTop=kJustRight,    /* put the parent above its children */
  52.         kJustBottom=kJustLeft    /* put the parent below its children */
  53.     } justStyle;
  54.  
  55.  
  56.  
  57. class CPPVisualTreeNode : public CPPTreeNode {
  58.         friend    class CPPVisualTree;
  59. public:
  60.     Boolean    needsResize;
  61.     Boolean    needsMove;
  62.     Boolean    needsDraw;
  63.     Boolean    notYetPlaced;
  64.     
  65.             CPPVisualTreeNode (CPPObject *NodeData, CPPTree *BelongsTo, 
  66.                                Boolean becomeOwner, Boolean selected);
  67.             ~CPPVisualTreeNode (void);
  68.             
  69.     virtual    char *ClassName (void);
  70.     virtual    Boolean    Member (char *className);
  71.         
  72.     virtual CPPObject *Clone(void);
  73.  
  74.     virtual    void    DrawJoin (CPPVisualTreeNode *FromNode,
  75.                               CPPVisualTreeNode *ToNode);
  76.     virtual    void    EraseJoin (CPPVisualTreeNode *FromNode,
  77.                               CPPVisualTreeNode *ToNode);
  78.     virtual    void    DrawNodeData (void);
  79.     
  80.             void    DrawNode (Boolean wholeFamily, Boolean forceDraw);
  81.     virtual    void    EraseNode (Boolean wholeFamily);
  82.             void    ResizeFamily (Boolean wholeFamily);
  83.             void    MoveFamily (Point *topLeft);
  84.             
  85.     virtual    void    CalcNodeSize (void);        
  86.             void     CalcFamilySize(void);
  87.             void     CalcFamilyBounds(Point TopLeftCorner);
  88.     
  89.     static    long    NumSelectedNodes (CPPVisualTreeNode *theNode);
  90.  
  91.             Boolean    CanDraw (void);
  92.  
  93.     inline    Boolean    IsSelected (void) {return this->isSelected;}
  94.             void    SetSelect (short selectType, Boolean selectFamily,
  95.                                Boolean doRedraw);
  96.         
  97.             void    GetAnchorPoints (Point *Left, Point *Right, 
  98.                                      Point *Top, Point *Bottom);
  99.             
  100.     virtual    void    ReceiveMessage (CPPGossipMonger *toldBy, 
  101.                                     short reason, void* info);
  102.     virtual    void    GetFamilyBounds (Rect *bounds);
  103.         
  104.             CPPVisualTreeNode *PointInNode (Point clickPt);
  105.  
  106.             void    DoOnFamilyInRect (Rect *theRect, Boolean fullyInside, 
  107.                                        ApplyProc theProc, long param);
  108.         
  109.     virtual    void    DoDoubleClick (short modifiers);
  110.     virtual    void    DoSingleClick (short modifiers);
  111.         
  112. protected:
  113.     Point    nodeSize,
  114.             childSize,
  115.             familySize;
  116.     Rect    nodeRect,    // the rectangle surrounding the node
  117.             childRect,    // surrounds the node's immediate children
  118.             gChildRect,    // surrounds all of the node's descendants
  119.             familyRect;    // surrounds the node & all its descendants
  120.             
  121.     virtual    void         DoCalcFamilySize(void);
  122.     virtual    void         DoCalcFamilyBounds (Point TopLeftCorner);
  123.             
  124.             short        GetNodeMargin (void);
  125.             orientStyle    GetOrientation (void);
  126.             justStyle    GetJustification (void);
  127.             joinTypes    GetJoinType (void);
  128.             short        GetBranchLength (void);
  129.     
  130.     Boolean    isSelected;
  131.     
  132. };
  133.  
  134.